﻿@model ArsenalManagement.Models.User

@{
    ViewData["Title"] = "Create";
}

<body>
<h1>用户注册</h1>


<hr />
<div class="row h-100 align-items-center justify-content-center" style="min-height: 100vh;">
    <div class="col-12 col-sm-8 col-md-6 col-lg-5 col-xl-4">
        <div class="bg-light rounded p-4 p-sm-5 my-4 mx-3">
            <form asp-action="Create">
                <div asp-validation-summary="ModelOnly" class="text-danger"></div>
                <div class="form-group">
                    <label asp-for="Username" class="control-label">用户名：</label>
                    <input asp-for="Username" class="form-control" />
                    <span asp-validation-for="Username" class="text-danger"></span>
                    @ViewData["msg"]
                </div>
                <div class="form-group">
                    <label asp-for="Password" class="control-label">密码：</label>
                    <input asp-for="Password" class="form-control" />
                    <span asp-validation-for="Password" class="text-danger"></span>
                </div>
                <div class="d-flex align-items-center justify-content-between mb-4">
                    <div class="form-group ">
                        <label class="form-check-label">军官
                            <input class="form-check-input" asp-for="Authority" /> @Html.DisplayNameFor(model => model.Authority)
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <input type="submit" value="注册" class="btn btn-primary py-3 w-100 mb-4" />
                </div>
            </form>
            <div>
                <a asp-controller="Home" asp-action="Index" class="text-center mb-0">返回登录</a>
            </div>
        </div>
    </div>
</div>





@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
</body>

<script>
        //这是一个JS自执行函数，在该函数创建完成后将会自动调用，因为页面的JS是按照顺序执行的，所以将它放在页面Body的最底部，将会在页面渲染完成自动执行
    !function () { //函数接收msg和redrectUrl两个参数，第一个为提示内容，第二个为跳转地址
        if (@ViewData["msg"])//如果存在msg则弹出
        {
            alert(msg);
        }            
    }
            
</script>
